package com.sigmazero13.gameutils.model;

public class GameInfoCustom {
	private GameInfo parentGame;
	private Integer minPlayers;
	private Integer maxPlayers;
	
	public GameInfoCustom() {
	}
	
	public GameInfoCustom(GameInfo parentGame) {
		this.parentGame = parentGame;
	}
	
	public GameInfo getParentGame() {
		return parentGame;
	}
	
	public void setParentGame(GameInfo parentGame) {
		this.parentGame = parentGame;
	}
	
	public Integer getMinPlayers() {
		return (minPlayers == null || minPlayers == 0) ? null : minPlayers;
	}
	
	public void setMinPlayers(Integer minPlayers) {
		this.minPlayers = minPlayers;
	}
	
	public Integer getMaxPlayers() {
		return (maxPlayers == null || maxPlayers == 0) ? null : maxPlayers;
	}
	
	public void setMaxPlayers(Integer maxPlayers) {
		this.maxPlayers = maxPlayers;
	}
	
	public boolean isEmpty() {
		boolean empty = true;
		if (minPlayers != null && minPlayers != 0 && (parentGame == null || minPlayers != parentGame.getMinPlayers(false)))
			empty = false;
		
		if (maxPlayers != null && maxPlayers != 0 && (parentGame == null || maxPlayers != parentGame.getMaxPlayers(false)))
			empty = false;
		
		return empty;
	}
	
	@Override
	public boolean equals(Object o) {
		if (!(o instanceof GameInfoCustom)) return false;
		
		GameInfoCustom other = (GameInfoCustom)o;
		return (minPlayers == other.getMinPlayers() && maxPlayers == other.getMaxPlayers());
	}
}
